package com.pku.smart.account.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.pku.smart.account.entity.AccountPayChannel;
import com.pku.smart.account.mapper.AccountPayChannelMapper;
import com.pku.smart.account.service.IAccountPayChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AccountPayChannelServiceImpl implements IAccountPayChannelService {

    @Autowired
    AccountPayChannelMapper accountPayChannelMapper;

    /**
     * 根据渠道编码查询支付渠道
     *
     * @param channelId
     * @return
     */
    @Override
    public AccountPayChannel getPayChannel(String mchId, String channelId) {
        QueryWrapper<AccountPayChannel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("mch_id",mchId);
        queryWrapper.eq("channel_id",channelId);
        AccountPayChannel channel = accountPayChannelMapper.selectOne(queryWrapper);
        return channel;
    }

    /**
     * 根据商户编号查询支付渠道
     *
     * @param mchId
     * @return
     */
    @Override
    public List<AccountPayChannel> getPayChannelList(String mchId) {
        QueryWrapper<AccountPayChannel> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("mch_id",mchId);
        List<AccountPayChannel> channelList = accountPayChannelMapper.selectList(queryWrapper);
        return channelList;
    }
}
